package com.es.set;

import com.es.linklist.AbstractLinkedList;
import com.es.linklist.DummyLinkedList;

/**
 * @author 二十
 * @since 2022/1/17 8:20 下午
 */
public class LinkedListSet<E> extends AbstractSet<E> {

    private AbstractLinkedList<E> list = new DummyLinkedList<>();
    @Override
    public void add(E e) {
        if (list.contains(e)){
            return;
        }
        list.addFirst(e);
    }

    @Override
    public void remove(E e) {
        list.deleteElement(e);
    }

    @Override
    public boolean contains(E e) {
        return list.contains(e);
    }

    @Override
    public int getSize() {
        return list.getSize();
    }

    @Override
    public boolean isEmpty() {
        return list.getSize()==0;
    }

    @Override
    public String toString() {
        return list.toString();
    }
}
